<?php

namespace App\Admin\Actions\UserAction;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;

class BankCardBindDismiss extends RowAction
{
    public $name = '银行卡解绑';
    
    public function handle(Model $model)
    {
    	if (!$model->cert_number) {
    		return $this->response()->error('银行卡未绑定');
	    }
    	
    	$model->update([
		    'real_name' => null,
		    'cert_number' => null,
		    'bank_name' => null,
		    'bank_abbr' => null
	    ]);
    	
	    return $this->response()->success('银行卡解绑成功')->refresh();
    }
	
	public function dialog()
	{
		$this->confirm('确定解除当前用户的银行卡绑定?');
	}
}
